home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_13_01
/
allison
/
copy2.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1994-11-02
|
420 b
|
22 lines
LISTING 5 - A Function that copies a file via block I/O
/* copy2.c */
#include <stdio.h>
int copy(FILE *dest, FILE *source)
{
size_t count;
static char buf[BUFSIZ];
while (!feof(source))
{
count = fread(buf,1,BUFSIZ,source);
if (ferror(source))
return EOF;
if (fwrite(buf,1,count,dest) != count)
return EOF;
}
return 0;
}